');
var jQuery;
var schoolaxisEventsData = {"mode":"school","events":[]};
var schoolaxisEventsHost = "ghastaging.schoolaxis.com";
var schoolaxisEventsScheme = "https";
var schoolaxisEventsRecaptchaHtml = "";
var schoolaxisEventsSubmitting = false;
if (window.jQuery === undefined || window.jQuery.fn.jquery !== "3.1.0") {
var script_tag = document.createElement("script");
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src", "https://code.jquery.com/jquery-3.1.0.min.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function () {
if (this.readyState == "complete" || this.readyState == "loaded") schoolaxisEventsScriptLoadHandler();
};
} else {
script_tag.onload = schoolaxisEventsScriptLoadHandler;
}
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
jQuery = window.jQuery;
schoolaxisEventsMain();
}
function schoolaxisEventsScriptLoadHandler() {
jQuery = window.jQuery.noConflict(true);
schoolaxisEventsMain();
}
function schoolaxisEventsMain() {
jQuery(document).ready(function($) {
schoolaxisEventsRenderRoot();
});
}
function schoolaxisEventsRenderRoot() {
var $root = jQuery("#schoolaxiseventsembed");
$root.html("");
if ( schoolaxisEventsData.mode == "school" ) {
schoolaxisEventsRenderEventList($root, schoolaxisEventsData.events);
} else {
schoolaxisEventsRenderInstanceList($root, schoolaxisEventsData.event, schoolaxisEventsData.event.instances);
}
}
function schoolaxisEventsEsc(s) {
return jQuery("
").text(s == undefined ? "" : s).html();
}
function schoolaxisEventsFormatDate(dt) {
if ( !dt ) return "";
var d = new Date(dt.replace(" ", "T"));
if ( isNaN(d.getTime()) ) return dt;
return d.toLocaleDateString(undefined, {weekday:"long", month:"long", day:"numeric", year:"numeric"});
}
function schoolaxisEventsFormatTime(dt) {
if ( !dt ) return "";
var d = new Date(dt.replace(" ", "T"));
if ( isNaN(d.getTime()) ) return dt;
return d.toLocaleTimeString(undefined, {hour:"numeric", minute:"2-digit", hour12:true});
}
function schoolaxisEventsRow(label, value) {
return "
" + label + ": " + value + "
";
}
function schoolaxisEventsRenderEventList($root, events) {
var html = '
';
if ( events.length == 0 ) {
html += '
No events are currently open for booking.
';
}
for ( var i = 0; i < events.length; i++ ) {
var ev = events[i];
html += '
';
html += '
' + schoolaxisEventsEsc(ev.name) + "
";
if ( ev.duration ) html += schoolaxisEventsRow("Duration", schoolaxisEventsEsc(ev.duration));
if ( ev.location ) html += schoolaxisEventsRow("Location", schoolaxisEventsEsc(ev.location));
if ( ev.instances.length == 0 ) {
html += '
No upcoming times available.
';
} else {
html += schoolaxisEventsRow("Available Times", ev.instances.length);
html += schoolaxisEventsRow("Next Available", schoolaxisEventsFormatDate(ev.instances[0].datetime));
html += " ";
html += '';
}
html += "
";
}
html += "
";
$root.html(html);
window.schoolaxisEventsEventsCache = events;
}
function schoolaxisEventsShowInstances(idx) {
var ev = window.schoolaxisEventsEventsCache[idx];
schoolaxisEventsRenderInstanceList(jQuery("#schoolaxiseventsembed"), ev, ev.instances, true);
}
function schoolaxisEventsRenderInstanceList($root, event, instances, showBack) {
// Callers that come back from the booking form do not pass showBack: in a school embed the list always has a way back to all events.
if ( showBack === undefined ) showBack = ( schoolaxisEventsData.mode == "school" );
var html = "";
if ( showBack ) html += '
';
for ( var i = 0; i < instances.length; i++ ) {
var inst = instances[i];
html += '
';
html += schoolaxisEventsRow("Date", schoolaxisEventsFormatDate(inst.datetime));
html += schoolaxisEventsRow("Time", schoolaxisEventsFormatTime(inst.datetime) + (inst.tz ? " " + schoolaxisEventsEsc(inst.tz) : ""));
if ( inst.duration ) html += schoolaxisEventsRow("Duration", schoolaxisEventsEsc(inst.duration));
if ( inst.location ) html += schoolaxisEventsRow("Location", schoolaxisEventsEsc(inst.location));
html += schoolaxisEventsRow("Available Spots", inst.remaining);
if ( inst.description ) html += schoolaxisEventsRow("Details", schoolaxisEventsEsc(inst.description));
html += " ";
html += '';
html += "
";
}
html += "
";
}
jQuery(($root && $root.length) ? $root : "#schoolaxiseventsembed").html(html);
window.schoolaxisEventsInstancesCache = instances;
window.schoolaxisEventsCurrentEvent = event;
}
function schoolaxisEventsShowBookingForm(idx) {
var inst = window.schoolaxisEventsInstancesCache[idx];
var event = window.schoolaxisEventsCurrentEvent;
var maxGuests = Math.max(0, inst.remaining - 1);
var html = '